package org.example.controller;

import lombok.RequiredArgsConstructor;
import org.example.dto.OrderDTO;
import org.example.dto.PrintRequest;
import org.example.service.OrderService;
import org.example.service.PrinterService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/print")
@RequiredArgsConstructor
public class PrintController {

    private final PrinterService printerService;
    private final OrderService orderService;

    @PostMapping("/order")
    public String printOrder(@RequestBody PrintRequest printRequest) {
        OrderDTO order = orderService.getOrderById(printRequest.getOrderId());
        printerService.printOrder(order, printRequest);
        return "打印指令已发送";
    }
}
